package dataModifiers;

import java.util.List;
import java.util.Random;

import inputs.Input;

/**
 * RandomOfInputs Modifier class
 * Extends Modifier functionality
 * 
 * Outputs a random input.
 * 
 * @author Dylan James
 *
 */
public class RandomOfInputs extends Modifier{
	private static Random rn = new Random();
	
	public RandomOfInputs(List<Input> inputs)
	{
		super(inputs);
	}
	
	@Override
	protected void Initialize() {
	}
	
	@Override
	protected void AccountForInputs() {
		if (inputs.size() > 0)
		{
			this.min = inputs.get(0).getMin();
			this.max = inputs.get(0).getMax();
			
			for (Input input : inputs)
			{
				if (input.getMin() < this.min)
					this.min = input.getMin();
				
				if (input.getMax() > this.max)
					this.max = input.getMax();
			}
		}
		else
		{
			this.min = 0;
			this.max = 0;
		}
	}


	@Override
	protected void Update() {
		this.value = inputs.get(rn.nextInt(inputs.size())).getValue();
	}

}
